<script setup lang="tsx">/**
 * 项目销售管理 - 项目金额
 */

import {ref,nextTick} from "vue";
import {defineDialogSheetForm, DialogSheetForm,processRequest} from "@/framework";
import {ElMessage} from "element-plus"


const emit = defineEmits<{
  (e: "confirm"): void
}>()


const dialogSheetFormModelRef = ref()
const form = defineDialogSheetForm<any>({
  title: "新增/编辑",
  width: 500,
  sheetForm:{
    labelWidth:"100px",
    required:['payAmount'],
    els:[
      {
        label: "下定金额",
        eType: "el-input-number",
        prop: "totalAmount",
        props: {
          placeholder: "下定金额",
          min: 0
        },
        style: {
          width: "100%"
        }
      }
    ]
  }
})

/**
 * 显示
 */
const show = (params: any) => {
  dialogSheetFormModelRef.value.addForm()
  nextTick(() => {
    dialogSheetFormModelRef.value.setFormData({
      id: params.id,
    })
  })
}


/**
 * 提交
 */
const handleSubmit = async (data: any) => {
  if (!data) return false
  await processRequest.post('/api/DevelopProjectSale/DepositAmount', {
    ...data
  })
  emit("confirm")
  ElMessage.success("新增成功")
  dialogSheetFormModelRef.value.close()
}

/**
 * 暴露
 */
defineExpose({
  show
})


</script>

<template>
  <DialogSheetForm ref="dialogSheetFormModelRef" :dialogSheetFormModel="form" @submit="handleSubmit"/>
</template>

<style scoped lang="scss">

</style>